package com.earthea.scaffold.domain;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.earthea.scaffold.common.entity.BaseInsertableEntity;
import com.earthea.scaffold.common.enums.CommonStatusEnum;
import com.earthea.scaffold.common.enums.MenuTypeEnum;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.ArrayList;
import java.util.List;

@Getter
@Setter
@ToString
@TableName("t_menu")
public class Menu extends BaseInsertableEntity {
    /**
     * 菜单ID
     */
    @TableId(type = IdType.AUTO)
    private Long menuId;

    /**
     * 菜单名称
     */
    @TableField(updateStrategy = FieldStrategy.NOT_EMPTY)
    private String menuName;

    /**
     * 父菜单ID
     */
    @TableField(insertStrategy = FieldStrategy.NOT_NULL, updateStrategy = FieldStrategy.NOT_EMPTY)
    private Long parentId;

    /**
     * 路由地址
     */
    @TableField(insertStrategy = FieldStrategy.NOT_NULL, updateStrategy = FieldStrategy.NOT_EMPTY)
    private String path;

    /**
     * 组件路径
     */
    @TableField(insertStrategy = FieldStrategy.NOT_NULL, updateStrategy = FieldStrategy.NOT_EMPTY)
    private String component;

    /**
     * 类型（M目录 C菜单 F按钮）
     */
    @TableField(updateStrategy = FieldStrategy.NOT_NULL)
    private MenuTypeEnum menuType;

    /**
     * 菜单状态（0正常 1停用）
     */
    @TableField(insertStrategy = FieldStrategy.NOT_NULL, updateStrategy = FieldStrategy.NOT_NULL)
    private CommonStatusEnum status;

    /**
     * 权限字符串
     */
    @TableField(insertStrategy = FieldStrategy.NOT_NULL, updateStrategy = FieldStrategy.NOT_EMPTY)
    private String perms;

    /**
     * 菜单图标
     */
    @TableField(insertStrategy = FieldStrategy.NOT_NULL, updateStrategy = FieldStrategy.NOT_EMPTY)
    private String icon;

    /**
     * 子菜单
     */
    @TableField(exist = false)
    private List<Menu> children = new ArrayList<>();
}
